﻿// CAddDlg.cpp: 实现文件
//

#include "pch.h"
#include "EmployeeManagement.h"
#include "afxdialogex.h"
#include "CAddDlg.h"


// CAddDlg 对话框

IMPLEMENT_DYNAMIC(CAddDlg, CDialogEx)

CAddDlg::CAddDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_ADD_DIALOG, pParent)
	, m_name(_T(""))
	, m_sex(FALSE)
	, m_department(_T(""))
	, m_job(_T(""))
	, m_jobid(0)
	, m_entyTime(COleDateTime::GetCurrentTime())
	, m_salary(0)
	, m_tel(_T(""))
	, m_adress(_T(""))
	, m_age(0)
	, m_sing(FALSE)
	, m_dance(FALSE)
	, m_rap(FALSE)
{

}

CAddDlg::CAddDlg(const CAddDlg& pDlg)
{
	m_name = pDlg.m_name;
	m_sex = pDlg.m_sex;
	m_department = pDlg.m_department;
	m_job = pDlg.m_job;
	m_jobid = pDlg.m_jobid;
	m_entyTime = pDlg.m_entyTime;
	m_salary = pDlg.m_salary;
	m_tel = pDlg.m_tel;
	m_adress = pDlg.m_adress;
	m_age = pDlg.m_age;
	m_sing = pDlg.m_sing;
	m_dance = pDlg.m_dance;
	m_rap = pDlg.m_rap;
	m_sing = pDlg.m_sing;
	m_dance = pDlg.m_dance;
	m_rap = pDlg.m_rap;
}

CAddDlg& CAddDlg::operator=(const CAddDlg& pDlg)
{
	m_name = pDlg.m_name;
	m_sex = pDlg.m_sex;
	m_department = pDlg.m_department;
	m_job = pDlg.m_job;
	m_jobid = pDlg.m_jobid;
	m_entyTime = pDlg.m_entyTime;
	m_salary = pDlg.m_salary;
	m_tel = pDlg.m_tel;
	m_adress = pDlg.m_adress;
	m_age = pDlg.m_age;
	m_sing = pDlg.m_sing;
	m_dance = pDlg.m_dance;
	m_rap = pDlg.m_rap;
	m_sing = pDlg.m_sing;
	m_dance = pDlg.m_dance;
	m_rap = pDlg.m_rap;
	return *this;
}

CAddDlg::~CAddDlg()
{
}

void CAddDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT2, m_name);
	DDX_Radio(pDX, IDC_RADIO1, m_sex);
	DDX_CBString(pDX, IDC_COMBO2, m_department);
	DDX_CBString(pDX, IDC_COMBO3, m_job);
	DDX_Text(pDX, IDC_EDIT1, m_jobid);
	DDX_Control(pDX, IDC_SPIN1, m_spinButton);
	DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_entyTime);
	DDX_Text(pDX, IDC_EDIT8, m_salary);
	DDX_Text(pDX, IDC_EDIT9, m_tel);
	DDX_Text(pDX, IDC_EDIT10, m_adress);
	DDX_Text(pDX, IDC_AGE_EDIT, m_age);
	DDV_MinMaxInt(pDX, m_age, 18, 80);
	DDX_Check(pDX, IDC_CHECK1, m_sing);
	DDX_Check(pDX, IDC_CHECK2, m_dance);
	DDX_Check(pDX, IDC_CHECK3, m_rap);
}


BEGIN_MESSAGE_MAP(CAddDlg, CDialogEx)
	ON_BN_CLICKED(IDOK, &CAddDlg::OnBnClickedOk)
END_MESSAGE_MAP()


// CAddDlg 消息处理程序


void CAddDlg::OnBnClickedOk()
{
	UpdateData(TRUE);
	if (m_name.IsEmpty() || m_department.IsEmpty() || m_job.IsEmpty() || m_tel.IsEmpty() || m_adress.IsEmpty())
	{
		MessageBox(_T("请输入完整信息"));
		return;
	}
	m_interest = "";
	if (m_sing)
		m_interest += _T("唱歌 ");
	if (m_dance)
		m_interest += _T("跳舞 ");
	if (m_rap)
		m_interest += _T("说唱 ");
	CDialogEx::OnOK();
}


BOOL CAddDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();
	m_spinButton.SetBuddy(GetDlgItem(IDC_AGE_EDIT));//设置伙伴控件
	m_spinButton.SetRange(18, 80);//设置范围
	//设置部门
	CComboBox* pdepatment = (CComboBox*)GetDlgItem(IDC_COMBO2);
	pdepatment->AddString(_T("技术部"));
	pdepatment->AddString(_T("销售部"));
	pdepatment->AddString(_T("人事部"));
	pdepatment->AddString(_T("财务部"));
	//设置职位
	CComboBox* pjob = (CComboBox*)GetDlgItem(IDC_COMBO3);
	pjob->AddString(_T("工程师"));
	pjob->AddString(_T("销售员"));
	pjob->AddString(_T("人事专员"));
	pjob->AddString(_T("财务专员"));



	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}

